<h1>Listing posts</h1>

<table>
  <tr>
    <th>Title</th>
    <th>Content</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @posts.each do |post| %>
  <tr>
    <td><%= post.title %></td>
    <td><%= post.content %></td>
    <% if can? :read, post %>
      <td><%= link_to 'Show', post %></td>
    <% end %>
    <% if can? :edit, post %>
      <td><%= link_to 'Edit', edit_post_path(post) %></td>
    <% end %>
    
    <% if can? :destroy, post %>
      <td><%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %></td>
    <% end %>
  
  </tr>
<% end %>
</table>

<br />

<% if can? :create, Post %>
  <%= link_to 'New Post', new_post_path %>
<% end %>
